
#include "board.h"

hal_pwm_t board_pwm[] = {
    {.group=T1, .ch=1}, {.group=T12, .ch=2}, {.group=T14, .ch=1}, {.group=T13, .ch=1}, 
    {.group=T8, .ch=3}, {.group=T8, .ch=4}, 
};

//PWM通道输出，Duty最大1000
void board_pwm_out(uint8_t index, uint16_t duty)
{
    if(index<BOARD_PWM_NUM) {
        
        if(duty==0)
            tmr_output_channel_mode_select(pwm_group[board_pwm[index].group], pwm_ch[board_pwm[index].ch-1],TMR_OUTPUT_CONTROL_FORCE_LOW); //强制输出0
        else if(duty>=1000)
            tmr_output_channel_mode_select(pwm_group[board_pwm[index].group], pwm_ch[board_pwm[index].ch-1],TMR_OUTPUT_CONTROL_FORCE_HIGH); //强制输出1
        else {
            tmr_output_channel_mode_select(pwm_group[board_pwm[index].group], pwm_ch[board_pwm[index].ch-1],TMR_OUTPUT_CONTROL_PWM_MODE_A); //PWM输出
            tmr_channel_value_set(pwm_group[board_pwm[index].group], pwm_ch[board_pwm[index].ch-1], duty);
        }
        
    }
}
